import { createRequest } from '/@/api/service';
const module = 'ib/base/v1/ScheduleAppApi/';

/**
 * @function APP查询交接记录
 * @param data
 * @param header
 * @returns {Promise}
 */
function APP_SCHEDULE_RECORD_LIST_QUERY(
  data: ScheduleAppApi.AppScheduleRecordListQueryReq,
  header: object = {},
): Promise<ScheduleAppApi.AppScheduleRecordListQueryRes> {
  return createRequest(
    `${process.env.APP_API_URL}${module}queryAppScheduleRecordList`,
    data,
    header,
    'POST',
  );
}

/**
 * @function 发起交接——获取当前登录用户的交接页面
 * @param data
 * @param header
 */

function APP_SCHEDULE_MODEL_QUERY(
  data: ScheduleAppApi.AppScheduleModelQueryReq,
  header: object = {},
): Promise<ScheduleAppApi.AppScheduleModelQueryRes> {
  return createRequest(
    `${process.env.APP_API_URL}${module}queryAppScheduleModel`,
    data,
    header,
    'POST',
  );
}

/**
 * 发起交接——查询该用户，对应班次下的可选择班时（返回对应班时和该班时在该交接班模板下的交接时间范围）
 */
function APP_SCHEDULE_TIME_LIST_BY_USER_QUERY(
  data: ScheduleAppApi.AppScheduleTimeListByUserQueryReq,
  header: object = {},
): Promise<ScheduleAppApi.AppScheduleTimeListByUserQueryResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}queryAppScheduleTimeListByUser`,
    data,
    header,
    'POST',
  );
}

/**
 * 发起交接——获取读数
 */
function APP_SCHEDULE_CONTENT_QUERY(
  data: ScheduleAppApi.AppScheduleContentQueryReq,
  header: object = {},
): Promise<ScheduleAppApi.AppScheduleContentQueryResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}queryAppScheduleContent`,
    data,
    header,
    'POST',
  );
}

/**
 * 发起交接——断点记录——填写完未提交，返回了前一页之前的操作
 */
function NOTE_APP_SCHEDULE_RECORD(
  data: ScheduleAppApi.NoteAppScheduleRecordReq,
  header: object = {},
): Promise<ScheduleAppApi.NoteAppScheduleRecordResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}noteAppScheduleRecord`,
    data,
    header,
    'POST',
  );
}

/**
 * 交接班——详情查看
 */
function APP_SCHEDULE_RECORD_DETAIL_QUERY(
  data: ScheduleAppApi.AppScheduleRecordDetailQueryReq,
  header: object = {},
): Promise<ScheduleAppApi.AppScheduleRecordDetailQueryResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}queryAppScheduleRecordDetail`,
    data,
    header,
    'POST',
  );
}

/**
 * 交接班动作——交接单新增（返回成功与否，并附带一个二维码）
 */
function INSERT_APP_SCHEDULE_RECORD(
  data: ScheduleAppApi.InsertAppScheduleRecordReq,
  header: object = {},
): Promise<ScheduleAppApi.InsertAppScheduleRecordResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}insertAppScheduleRecord`,
    data,
    header,
    'POST',
  );
}

/**
 * 交接班动作——交接单修改（返回成功与否，并附带一个二维码）
 */
function UPDATE_APP_SCHEDULE_RECORD(
  data: ScheduleAppApi.UpdateAppScheduleRecordReq,
  header: object = {},
): Promise<ScheduleAppApi.UpdateAppScheduleRecordResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}updateAppScheduleRecord`,
    data,
    header,
    'POST',
  );
}

/**
 * 交接班动作——接班确认（返回成功与否）
 */
function CHECK_APP_SCHEDULE_RECORD(
  data: ScheduleAppApi.CheckAppScheduleRecordReq,
  header: object = {},
): Promise<ScheduleAppApi.CheckAppScheduleRecordResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}checkAppScheduleRecord`,
    data,
    header,
    'POST',
  );
}

/**
 * 生成交接班二维码
 */
function GENERATE_APP_SCHEDULE_RECORD_QR_CODE(
  data: ScheduleAppApi.GenerateAppScheduleRecordQrCodeReq,
  header: object = {},
): Promise<ScheduleAppApi.GenerateAppScheduleRecordQrCodeResp> {
  return createRequest(
    `${process.env.APP_API_URL}${module}generateAppScheduleRecordQrCode`,
    data,
    header,
    'POST',
  );
}

export {
  APP_SCHEDULE_RECORD_LIST_QUERY,
  APP_SCHEDULE_MODEL_QUERY,
  APP_SCHEDULE_TIME_LIST_BY_USER_QUERY,
  APP_SCHEDULE_CONTENT_QUERY,
  NOTE_APP_SCHEDULE_RECORD,
  APP_SCHEDULE_RECORD_DETAIL_QUERY,
  INSERT_APP_SCHEDULE_RECORD,
  UPDATE_APP_SCHEDULE_RECORD,
  CHECK_APP_SCHEDULE_RECORD,
  GENERATE_APP_SCHEDULE_RECORD_QR_CODE,
};
